package com.shell.arouter.demo

import com.durian.ui.adapter.multi.ItemViewProvider
import com.durian.ui.adapter.multi.MultiItemViewHolder
import com.henanjianye.soon.communityo2o2.R
import com.shell.arouter.extend.toast

/**
 * 说明：IHomeAction
 * <p/>
 * 作者：fanly
 * <p/>
 * 类型：Class
 * <p/>
 * 时间：2019-12-19 17:00
 * <p/>
 * 版本：version 1.0
 */
interface IHomeAction {
    fun todo()
    fun name(): String
}

class HomeAction(clazz: Class<out IHomeAction>) {
    val action: IHomeAction? = clazz.newInstance()
}

class HomeActionProvider : ItemViewProvider<HomeAction>() {
    override fun convert(holder: MultiItemViewHolder, item: HomeAction, position: Int) {
        holder.setText(R.id.btn_action,item.action?.name())
        holder.setOnClickListener(R.id.btn_action) { item.action?.todo() }
    }
    override fun getItemLayoutId(): Int {
        return R.layout.item_home_one
    }

    override fun onDestroy() {
        super.onDestroy()
        "已经退出了".toast()
    }
}

